<?php

/**
 * playlist actions.
 *
 * @package    ilts
 * @subpackage playlist
 * @author     devlife
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class playlistActions extends sfActions
{
  public function executeAddToPlaylist()
  {
    if ($this->getRequest()->isMethod('POST'))
    {

      $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));

      if ($form->isValid())
      {
        $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';

        // NEW: deal with tags
        if ($form->getValue('remove_tags')) {
          foreach (preg_split('/\s*,\s*/', $form->getValue('remove_tags')) as $tag) {
            $form->getObject()->removeTag($tag);
          }
        }
        if ($form->getValue('new_tags')) {
          foreach (preg_split('/\s*,\s*/', $form->getValue('new_tags')) as $tag) {
            // sorry, it would be better to not hard-code this string
            if ($tag == 'Add tags with commas') continue;
            $form->getObject()->addTag($tag);
          }
        }

        try {
          $complaint = $form->save();
          // and the remainder is just pasted from the generated actions file
        } catch (Exception $e) {
        }
        $this->getResponse()->setContent('Salvataggio eseguito');
      }
    }
    else
    {
      $this->renderComponent('playlist', 'formAddToPlaylist');
    }
    $this->setTemplate(false);
    return sfView::NONE;
  }
  
  

}
